package com.yc.testparm;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TestRecursion3 {
	
	public Map<String, Integer> m1(String str) {
		
		Map<String, Integer> res = new HashMap<String, Integer>();
		String item = null;
		for (int i = 0; i < str.length(); i++) {
			item = str.substring(i, i + 1);
			Integer last = res.get(item.toLowerCase())==null?0:res.get(item.toLowerCase());
			res.put(item.toLowerCase(), last + 1);
		}
		
		return res;
	}

	public static void main(String[] args) {
		String aa = "aswnfasdnflkasajdflkajlfmdsfjaioerjrngjbuhfykhqnfa";
		TestRecursion3 tr = new TestRecursion3();
		Map<String, Integer> map = tr.m1(aa);
		
		int max = 0;
		List<String> maxStr = new ArrayList<String>();
		for (String key : map.keySet()) {
			System.out.println(key + "--" + map.get(key));
			if (map.get(key) == max) {
				maxStr.add(key);
			}
			
			if (map.get(key) > max) {
				max = map.get(key);
				maxStr.clear();
				maxStr.add(key);
			}
			
		}
		
		for (String s : maxStr) {
			System.out.println(s);
		}
		System.out.println("max=" + max);
		

	}

}
